﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;

namespace Tippelde.Web.Helpers
{
    public static class UrlExtensions
    {
        public static string ToSeoFriendlyUrl(this string text)
        {
            if (String.IsNullOrEmpty(text))
                return String.Empty;

            text = text.Normalize(NormalizationForm.FormD);

            var nonspace = new Regex("[^0-9A-Za-z ]");
            text = nonspace.Replace(text, String.Empty);

            text = text.Replace(' ', '-');

            string replaced = text.Trim('-');

            string ret = HttpUtility.UrlEncode(replaced);

            return String.IsNullOrEmpty(ret) ? "1" : ret;
        }
        public static string Format(this string text, params object[] args)
        {
            return String.Format(text, args);
        }


    }
}